package AddMoviePage;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.testng.*;
import org.testng.annotations.*;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class NegativeAddMovie extends javatitov.pages.TestBase {
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

 
 
 @Test
  public void isNegativeAddMovie() throws Exception {
	 driver.get(baseUrl + "/php4dvd/");
	    driver.findElement(By.cssSelector("img[alt=\"Add movie\"]")).click();
	    driver.findElement(By.name("name")).clear();
	    driver.findElement(By.name("name")).sendKeys("123");
	    driver.findElement(By.id("submit")).click();
	    System.out.println(isElementPresent(By.xpath("//label[@class='error'][@for='year'][text()='This field is required']"))); 
    }
    

 boolean isElementPresent(By by) {
	    try {
	        driver.findElement(by);
	        return true;
	    } catch (NoSuchElementException e) {
	        return false;
	    }
	}

}